// Copyright 叶湘 ( weixin:yexiang841, email:yexiang841@qq.com ), Shitouren Studio. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "Q3D_CPPU_Logger.generated.h"

/**
 * 
 */
UENUM(BlueprintType, Category = "Q3D_Logger", meta = (Tooltip = "日志级别(C++)：跟 UE_LOG 定义的级别一一对应"))
enum class EQ3D_CPPE_LogLevel : uint8
{
	Fatal = 7 UMETA(Tooltip = "Fatal"),
	Error = 6 UMETA(Tooltip = "Error"),
	Warning = 5 UMETA(Tooltip = "Warning"),
	Display = 4 UMETA(Tooltip = "Display"),
	Log = 3 UMETA(Tooltip = "Log"),
	Verbose = 2 UMETA(Tooltip = "Verbose"),
	VeryVerbose = 1 UMETA(Tooltip = "VeryVerbose"),
	All = 0 UMETA(Tooltip = "ALL"),
};

DECLARE_LOG_CATEGORY_EXTERN(__Q3D__, Log, All);

/**
 * 
 */
UCLASS(Blueprintable, ClassGroup = (Q3D), meta = (Tooltip = "日志工具类(C++)"))
class Q3D_LIB_API UQ3D_CPPU_Logger : public UObject
{
	GENERATED_BODY()

public:
	/*
	 * 是否打印到控制台
	 */
	static const bool Bool_Print_To_Console = true;

	/*
	 * 是否打印到屏幕
	 */
	static const bool Bool_Print_To_Screen = false;

	/*
	 * 是否打印到文件
	 */
	static const bool Bool_Print_To_File = false;

	/*
	 * 当前日志等级
	 */
	static const EQ3D_CPPE_LogLevel Enum_LogLevel_Config = EQ3D_CPPE_LogLevel::Verbose;

	/*
	 * 日志在屏幕上的停留时间
	 */
	static constexpr float Float_Log_Duration_Config = 80.0;

public:
	UFUNCTION(BlueprintCallable, Category = Q3D_Logger, meta = (Tooltip = "打印日志，蓝图和 C++ 都可调用，自动匹配日志级别，决定是否输出，会根据配置决定是否打印到屏幕"))
	static void Q3D_F_PrintLog(EQ3D_CPPE_LogLevel enum_loglevel, const FString &string_msg, const FString &string_log_source);

protected:
	/*
	 * 执行日志打印
	 * 自动匹配日志级别，决定是否输出；
	 * 会根据配置决定是否打印到屏幕；
	 */
	static void _F_PrintLog(EQ3D_CPPE_LogLevel enum_loglevel, const FString &string_log);
};

// Q3D_LOG
#define Q3D_LOG(LogLevel, Param1) UQ3D_CPPU_Logger::Q3D_F_PrintLog(EQ3D_CPPE_LogLevel::LogLevel, Param1, FString(__FILE_NAME__) + "(" + FString::FromInt(__LINE__) + ")" + "::" + FString(__FUNCTION__))
